package apcsif;  
  

import java.util.Random;
import java.util.Scanner;
/*
 * This is a placeholder for the world class. Write world class here.
 */
/*To Do
* bug test
 */
public class world {
    public static String locat = "upperOldMainNorth";
    //public static String locat = "tmac";
    static boolean sword = true;
    static boolean ductTape = true;
    static boolean belt = true;
    static boolean pepsiMax = true;
    static boolean keys = true;
    static boolean picks = true;
    static boolean torch = true;
    static boolean frenchBook = true;
    static boolean cake = true;
    static boolean cables = true;
    static boolean mirror  = true;
    static boolean tmac = true;
    static boolean amazon =true;
    static String pin;
    static Random rand;
    static Scanner scan = new Scanner(System.in);

    public static void upperOldMainNorth(String str) {
        switch (str) {
        case "l":
            System.out.println("You are in upper Old Main. Stairs lead down to the north. East is the computer lab. The hall continues to the south.");
            break;
        case "e":
            locat = "computerLab";
            computerLab("l");
            break;
        case "s":
            locat = "upperOldMainSouth";
            upperOldMainSouth("l");
            break;
        case "w":
            locat = "oldMainLounge";
            oldMainLounge("l");
            break;
        case "d":
        case "n":
            locat = "lowerOldMain";
            lowerOldMain("l");
            break;
        default:
            System.out.println("you can't do that");
            break;
        }
    }

    public static void computerLab(String str) {
        switch (str) {
        case "l":
           if(Globals.getHands().contains("pepsi Max"))
           {
            System.out.println("You are in the lab. Mr. Echols glares at you. Perhaps you should leave");
            if(!Globals.getHands().contains("mirror") || !Globals.getHands().contains("cables"))
            {
                System.out.println("Equip the needed items then look");
            }
            else
            {
                Globals.biWinning();
            }
            }
            else
            {
                System.out.println("You give Mr. Echols the Pepsi Max and he calms down.");
            }
            break;
        case "w":
            locat = "upperOldMainNorth";
            upperOldMainNorth("l");
            break;
        default:
            break;
        }
    }
    
    public static void oldMainLounge(String str)
    {
        switch (str)
        {
            case "l":
                if(ductTape)
                {
                    System.out.println("This is the teacher's lounge. Nobody is here. There is a roll of " +
                        "\nduct tape sitting next to a computer. The computer is open to an email with the new security code 1864");

                    System.out.println("The hall is to the east.");
                }
                else{
                    System.out.println("This is the teacher's lounge. Nobody is here. The computer is open to an" 
                    + "\nemail with the new security code, 1864");
                    System.out.println("The hall is to the east.");
                }
                break;
            case "e": 
                locat = "upperOldMainNorth";
                upperOldMainNorth("l");
                break;
            case "t":
                if(ductTape == true)
                {
                    ductTape = false;
                    Globals.takeItem("duct tape");
                }
                else
                {
                    System.out.println("There's no " + Parser.param() + " here.");
                }
                break;
            default:
                break;
            }
    }
    public static void lowerOldMain(String str) {
        switch (str) {
        case "l":
            System.out.println("You are in lower Old Main hall. The Gym is to the east.");
            System.out.println("Doors lead out to the coutyard to the west. A set of stairs leads up.");
            System.out.println("The lockers are to the south.");
            break;
        case "u":
            locat = "upperOldMainNorth";
            upperOldMainNorth("l");
            break;
        case "w":
            locat = "upperCourtyard";
            upperCourtyard("l");
            break;
        case "e":
            locat = "gym";
            gym("l");
            break;
        case "s":
            locat = "lockers";
            lockers("l");
            break;
        default:
            break;
        }
    }

    public static void upperOldMainSouth(String str) {
        switch (str) {
        case "l":
            System.out.println("You are at the south end of Old Main's top floor. Stairs going down to the portables are in the south.");
            System.out.println(" The hall goes on to the north.To the east is Gallagher's class. To the west is Taberski's class");
            break;
        case "d":
            locat = "portables";
            portables("l");
            break;
        case "e":
            locat = "gallagher";
            gallagher("l");
            break;
        case "w":
            locat = "taberski";
            taberski("l");
            break;
        case "n":
            locat = "upperOldMainNorth";
            upperOldMainNorth("l");
            break;
        default:
            break;
        }
    }
    
    public static void taberski(String str)
    {
        switch(str)
        {
            case "l":
                if(sword)
                {
                System.out.println("Mr. Taberski is waving around a sword. Once he finishes, he puts it down on a desk");
              }
                else
                {
                    System.out.println("Mr. Taberski is teaching his class");
                }
                System.out.println("To the east is the southern hall.");
                break;
            case "e":
                if(sword)
                {
                    Sys.sp("Its dangerous to go alone. Take this");
                    Globals.takeItem("sword");
                    sword = false;
                    scan.nextLine();
                }
                locat = "upperOldMainSouth";
                upperOldMainSouth("l");
                break;
            case "t":
                Sys.sp("Just wait a sec");
                break;
            default:
                break;
        }
    }
    
    public static void gallagher(String str)
    {
        switch(str)
        {
            case "l":
                System.out.println("You are in Gallagher's class. She is watching a debate on wheather\nor not the church is right. She helps both sides.");
                System.out.println("To the west is the southern hall.");
                break;
            case "w":
                System.out.println("You take a Jesus Jolly as you leave.");
                locat = "upperOldMainSouth";
                upperOldMainSouth("l");
                break;
            default:
                break;
            
        }
    }
    public static void gym(String str) {
        switch (str) {
        case "l":
            System.out.println("You are in the gymnasium. Some freshman are playing Ultimate. The hall is to the west");
            break;
        case "w":
            System.out.println("As you turn to leave, a frisbee hits you in the back of the head.");
            locat = "lowerOldMain";
            lowerOldMain("l");
            break;
        default:
            break;
        }
    }
    public static void lockers(String str)
    {
        switch(str)
        {
            case "l":
                if(belt == true)
                {
                    System.out.println("You are in the boy's locker room. Nobody else is here. One of the lockers\n" +
                    "is open and there is a belt inside. The exit is back north.");
                }
                else
                {
                    System.out.println("You are in the boy's locker room. Nobody else is here. One of the lockers\n" +
                    "is open. The exit is back north.");
                }
                break;
            case "t":
                if(belt == true)
                {
                    Globals.takeItem("belt");
                    belt = false;
                }
                else{
                    System.out.println("There's no " + Parser.param() + " here.");
                }
                break;
            case "n":
                locat = "lowerOldMain";
                lowerOldMain("l");
                break;
            default:
                break;
        }
    }
    public static void portables(String str)
    {
        switch (str)
        {
            case "l":
                System.out.println("You are at the portables. the one to the east is the robotics one.");
                System.out.println("It seems that they have installed a pin security system. There are");
                System.out.println("stairs that lead back up to Old Main's second floor.");
                break;
            case "e":
                System.out.print("What is the pin? Konami code will also work\n>");
               
                pin = scan.nextLine();
                if(pin == "1864" || pin == "up up down down left right left right b a start" || pin == "up, up, down, down, left, right, left, right, b, a, start")
                {
                    System.out.println("Access granted");
                    locat = "roboticsRoom";
                    roboticsRoom("l");
                    break;
                }
                else
                {
                    System.out.println("Access Denied");
                    break;
                }
            case "u":
                locat = "upperOldMainSouth";
                upperOldMainSouth("l");
                break;
            default:
                break;
        }
    }
    public static void roboticsRoom(String str)
    {
        switch(str)
        {
            case "l":
                System.out.println("You have made it into the robotics room. Gary is here hammering iron plate armor.");
                scan.nextLine();
                System.out.print("Gary: ");
                Sys.sp("What's up "+ Globals.name() +"?");
                scan.nextLine();
                System.out.println("You quickly explain your predicament. Gary sits stone faced as he fastens leather to the plates");
                scan.nextLine(); 
                Sys.sp("This realm is a mirror of yours? Ive heard worse.");
                scan.nextLine();
                Sys.sp("If you want to get back, youre going to need a mirror and some cables");
                scan.nextLine();
                Sys.sp("I'll put in an order for a mirror through Amazon. Thoes drones have been \ndelivering them to the heath hall roof though. The cables you are going to have to find.");
                scan.nextLine();
                if(picks == true)
                {
                    Sys.sp("Take these. You will need them");
                    Globals.takeItem("picks");
                    picks = false;
                }
                scan.nextLine();

                System.out.println("The exit is to the west");
                break;
            case "w":
                locat = "portables";
                portables("l");
                break;
            default:
                break;
        }
    }
    public static void upperCourtyard(String str) {
        switch (str) {
        case "l":
            System.out.println("You are standing in the courtyard. It looks like it might rain later.");
            System.out.println("To your east is Old main. Heath Hall is to the south.\nGrace Hall is to the North. Stairs lead down to the parking lot.");
            break;
        case "e":
            locat = "lowerOldMain";
            lowerOldMain("l");
            break;
        case "s":
            locat = "heathHall1East";
            heathHall1East("l");
            break;
        case "n":
            locat = "cafeteria";
            cafeteria("l");
            break;
        default:
            break;
        }
    }
    public static void cafeteria(String str)
    {
        switch(str)
        {
            case "l":
                System.out.println("You are in the cafeteria.It smells like Mexican food.");
                System.out.println("There are stairs to the east.There is are stairs going up. The freshman lockers are to the east.");
                System.out.println("North leads back to the courtyard.");
                if (pepsiMax == true)
                {
                    System.out.println("There is a Pepsi Max on the table");
                }
                break;
            case "u":
                locat = "upperGraceHall";
                upperGraceHall("l");
                break;
            case "n": 
                locat = "courtyard";
                upperCourtyard("l");
                break;
            case "e":
                locat = "freshmanLockers";
                freshmanLockers("l");
                break;
            case "t":
                if(pepsiMax == true)
                {
                    Globals.takeItem("pepsi max");
                    pepsiMax = false;
                }
                else
                {
                    System.out.println("There is no " + Parser.param() + " here.");
                }
                break;
            default: 
                break;
        }
    }
    public static void freshmanLockers(String str)
    {
        switch(str)
        {
            case "l":
                System.out.println("You are in the freshman lockers. To the west is Mr. Brodniac's room. To the");
                System.out.println("east is Mr. Brodniack room. To the south is the courtyard. There is a set of stairs");
                System.out.println("going up. The cafeteria is back east.");
                break;
            case "e":
                locat = "brodniak";
                brodniak("l");
                break;
            case "s":
                locat = "upperCourtyard";
                upperCourtyard("l");
                break;
            case "u":
                locat = "upperGraceHall";
                upperGraceHall("l");
                break;
            case "w":
                locat = "cafeteria";
                cafeteria("l");
                break;
            default:
                break;
        }
    }
    public static void brodniak(String str)
    {
        switch(str)
        {
            case "l":
                System.out.println("You are in Mr. Brodniak's GOPO room. It is currently empty and you");
                System.out.println("wonder why the door was unlocked. The courtyard is to the east.");
                System.out.println("TMAC's room is to the south. The freshman lockers are to the west.");
                break;
            case "s":
                locat = "tmac";
                tmac("l");
                break;
            case "e":
                        locat = "upperCourtyard";
                upperCourtyard("l");
                break;
            case "w":
                locat = "freshmanLockers";
                freshmanLockers("l");
                break;
            default:
                break;
        }
    }
    public static void tmac (String str)
    {

        rand = new Random();
        switch (str) 
        {
        case "l": 
            if(tmac)
            {
                System.out.println("You are greated by a round of applause");
                System.out.println("You are in Mr. McLaughlin's classroom. He looks ready to attack");
                System.out.println("On his desk you see a set of keys. Those might be useful");
            }
            else
                System.out.println("You are in Mr. McLaughlin's room. The door to Brodiak is to your north");
            break;
        case "t":
            if (tmac){
                System.out.println("You reach for the keys but Tmac stands in your way.");
            }
            else 
            {
             if(keys == true){
                Globals.takeItem("keys");
                keys = false;
                }
                else
                {
                    System.out.println("There is no " + Parser.param() +" here.");
                }
            }
            break;
        case "a":
            if(tmac){
                if(Globals.getHands().contains("sword")){
                    if(rand.nextInt(10)>=5){
                        tmac = false;
                        System.out.println("You attack Tmac with the sword. He tries to defend himself, but is no match for your swordfighting abilities.");
                    }
                    else
                    {
                        System.out.println("You swing your sword at tmac, but he dodges the attack.");
                    }
                }
                else{
                    System.out.println("You need something to attack him with. Something like a sword should work");
                }
            }
            else{
                System.out.println("There is no one here to attack");
            }
        break;
        case "n":
            System.out.println("The class aplauds as you leave");
            locat = "brodniak";
            brodniak("l");
            break;
        default: break;

      
            }
        }
        
    public static void upperGraceHall(String str)
    {
        switch (str)
        {
            case "l":
                System.out.println("You are at the senior lockers. The library is to the south.");
                System.out.println("To the east is the computer lab. To the west is Zelner's room.");
                System.out.println("There are stairs going down.");
                break;
            case "n": 
                locat = "cafeteria";
                cafeteria("l");
                break;
            case "e":
                locat = "compLab";
                compLab("l");
                break;
            case "w":
                locat = "zelner";
                zelner("l");
                break;
            case "d":
                locat = "cafeteria";
                cafeteria("l");
                break;
            case "s":
                locat = "library";
                library("l");
                break;
            default:
                break;
        }
    }
    public static void library(String str)
    {
        switch (str)
        {
            case "l": 
                System.out.println("You are in the library. There are some kids playing The Library");
                System.out.println("in Halo: Combat Evolved and not getting thier asses kicked by the Flood.");
                if(frenchBook == true)
                {
                    System.out.print("There is a french book on the shelf. ");
                }
                System.out.println("The hall is to the north.");
                break;
            case "n":
                locat = "upperGraceHall";
                upperGraceHall("l");
                break;
            case "t": 
                if(frenchBook)
                {
                Globals.takeItem("french book");
                frenchBook = false;
                }
                break;
            default:
                break;
        }
    }
    public static void compLab(String str)
    {
        switch (str)
        {
            case "l":
                System.out.println("This is Mr. Hitchcock room. He is wearing all white today.");
                System.out.println("There is a slice of cake on a desk. The senior lockers are back west.");
                break;
            case "w":
                locat = "upperGraceHall";
                upperGraceHall("l");
                break;
            case "t":
                System.out.println("This cake is a lie");
                break;
            default:
                break;
        }
    }
    public static void zelner(String str)
    {
        switch(str)
        {
            case "l":
                if(!Globals.getHands().contains("cake"))
                {
                    Sys.sp("If you want to be in the NHS meeting, bring cake!");
                    scan.nextLine();
                    locat = "upperGraceHall";
                    upperGraceHall("l");
                    }
                else
                {
                    Sys.sp("Welcome to the NHS meering!");
                    if(cables)
                    {
                        System.out.print("There is a set of cables on her desk");
                    }
                    System.out.println("The senior lockers are to the east.");
                }
                break;
            case "e":
                locat = "upperGraceHall";
                upperGraceHall("l");
                break;
            default:
                break;
        }
    }
    public static void heathHall1East(String str){
        bad:
        switch(str){
        case "l": System.out.println("You are at the eastern end of Heath Hall. French class is to the north. Spanish is to the south. The hall goes on to the west. Doors lead out to the east.");
        System.out.println("There are stairs going up");
        break;
        case "n":
            locat = "france";
            france("l");
            break;
        case "s":
            locat = "spain";
            spain("l");
            break;
        case "w": 
            locat = "heathHall1West";
            heathHall1West("l");
            break;
        case "e":
            locat = "upperCourtyard";
            upperCourtyard("l");
            break;
        case "u":

        if(!Globals.getHands().contains("torch"))
        {
        System.out.println("You enter the stairwell. It is dark. You are likely to be eaten by a grue.");
    
        System.out.print("The hall is back north\n>");
        String maddaesome = scan.nextLine();
        switch(maddaesome.toLowerCase().trim())
        {
                case "n": case "north":
                System.out.println("You are back in the hallway");
                break bad;
                default: 
                    System.out.println("You were eaten by the grue. (Told ya so -J)");
                    Globals.gameOver();
                    break bad;
            }
       }
       else
       {
           System.out.println("The torch illuminates the stairwell and you go up");
           locat = "upperHeathHallEast";
           upperHeathHallEast("l");
           break bad;
       }

        default: break;
        }
     }
    public static void france(String str){
        switch(str){
        case "l": 
        if(!Globals.getHands().contains("french book"))
        {
            System.out.println("You are in the French Classroom. Ms. Kenny babbles something at you in french about not bei g one of her students");
            System.out.println("She looks angry. You should probably leave.");
       }
        else
        {
            System.out.println("Ms. Kenny mistakes you for one of her french students.");
            scan.nextLine();
            if(cake == true)
            {
                Sys.sp("Bonjour! We only have one slice of cake left.");
            }
        }
       break;
        case "s":
            locat = "heathHall1East";
            heathHall1East("l");
            break;
       case "t": 
           if(cake)
           {
               Globals.takeItem("cake");
               cake = false;
           }
           else
           {
               System.out.println("Theres no "+Parser.param()+" here");
           }
           break;
        default: break;
        }
    }
    public static void spain(String str){
        switch(str){
        case "l": System.out.println("You are in the Spanish classroom.");break;
        case "n": 
            locat = "heathHall1East";
            heathHall1East("l");
        default: break;
        }
    }
    public static void heathHall1West(String str){
        switch(str){
        case "l":
            System.out.println("You are at the west end of Heath hall. An elevator goes up. Mrs. Mock's classroom is to the west. South is Moynihan's classroom.");
            break;
        case "e":
            locat = "heathHall1East";
            heathHall1East("l");
            break;
        case "u":
            break;
        case "w":
            locat = "mock";
            mock("l");
            break;
        case "s":
            locat = "moynihan";
            moynihan("l");
            break;
        default: break;
        }
    }
    public static void mock(String str)
    {
        switch(str)
        {
        case "l":
            System.out.println("Mrs. Mock is teaching geometry. Some kids in the back corner are making");
            System.out.println("a program to do the entire lesson. The exit is east");
            break;
        case "e":
            locat = "heathHalllWest";
            heathHall1West("l");
            break;
            default:
            break;

        }
    }
    public static void moynihan(String str)
    {
        switch(str)
        {
            case "l": 
            System.out.println("Mr. Moynihan plauing Seven Nation Army on his saxaphone");
            System.out.println("The exit is north");
            break;
            case "n":
            locat = "heathHall1West";
            heathHall1West("l");
            break;
            default:
            break;
        }
    }
    public static void upperHeathHallWest(String str)
    {
        switch(str)
        {
            case "l": 
                System.out.println("You are on the upper floor of heath hall. The hall continues");
                System.out.println("to the east.There are stairs going down.");
                break;
            case "e":
                locat = "upperHeathHallEast";
                upperHeathHallEast("l");
                break;
            case "d":
                locat = "heathHall1East";
                heathHall1East("l");
                break;
            default: 
                break;
        }
    }
    public static void upperHeathHallEast(String str)
    {
        switch(str)
        {
            case "l": 
                System.out.println("You are in the east wing of Heath Hall. Mrs. Alkires room is to the east.");
                System.out.println("Mr. Glass' room is to the north. The janitors closet is to the south. A set of stairs leads down.");
                break;
            case "n":
                locat = "glass";
                glass("l");
                break;
            case "s":
                locat = "closet";
                closet("l");
                break;
            default: 
            break;
        }
    }
    public static void glass(String str)
    {
        switch (str)
        {
            case "l":
                if(torch)
                {
                System.out.println("Mr. Glass is cheerfuly teaching the dangers of meth to his class");
                System.out.println("There is a torch on the table. The exit is to the south.");
                }
                else
                {
                    System.out.println("Mr. Glass is cheerfuly teaching the dangers of meth to his class");
                    System.out.println("The exit is to the south");
                }
                break;
            case "t":
                Globals.takeItem(Parser.param());
                torch = false;
                break;
            case "s":
                locat = "upperHeathHallEast";
                upperHeathHallEast("l");
                break;
            default: 
            break;
        }
    }
    public static void closet(String str)
    {
        switch (str)
        {
            case "l":
                if(Globals.getHands().contains("torch"))
                {
                    System.out.print("The closet is dark. You should probably exit to the north before you get eaten by a grue.\n/");// change me
                    String command = scan.nextLine();
                    switch(command.toLowerCase())
                    {
                        case "n": case "north":
                            System.out.println("(smart move -J)");
                            locat = "upperHeathHallEast";
                            upperHeathHallEast("l");
                            break;
                        default:
                            System.out.println("You were eaten by a grue. (Told ya so -J)");
                            Globals.gameOver();
                            break;
                    }
                    }
                else
                {
                    System.out.println("The torch lights up the closet. There is a ladder going up to the roof.");
                    System.out.println("The exit is to the north.");
                }
                break;
            case "n": 
                locat = "upperHeathHallEast";
                upperHeathHallEast("l");
                break;
            case "u":
                if(Globals.getHands().contains("picks"))
                {
                    System.out.println("You pick the locks and climb the ladder up to the roof");
                    locat = "roof";
                    roof("l");
                }
                else
                {
                    System.out.println("You attempt to get to the roof but its padlocked. perhaps you should pick it");
                }
                break;
            default:
                break;
        }
    }
    public static void roof(String str)
    {
    switch(str)
    {
        case "l":
            if(amazon)
            {
            System.out.println("You are on the roof. There is a geen bin from Amazon but the Drone is going berzerk\nand you cant get to it");
            } 
            else
            {
                if (mirror)
                {
                    System.out.println("The mirror is in the bin, which lies open");
                }
                System.out.println("Theres nothing to do besides walk off the roof in any direction or go down the ladder");
            }
            break;
        case "a":
        if(amazon){
            if(Globals.getHands().contains("sword")){
                if(rand.nextInt(10)>=7){
                    amazon = false;
                    System.out.println("The robot crashes to the ground in a shower of sparks amd fan blades.");
                }
                else
                {
                    System.out.println("The delivery robot flies into the air to dodge.");
                }
            }
            else{
                System.out.println("You need something to attack it with. Something like a sword should work");
            }
        }
        else{
            System.out.println("There is nothing here to attack");
        }
        case "d":
            locat = "closet";
            closet("l");
            break;
        case "n": case "s": case "e": case "w":
            System.out.println("I cant believe you just did that.");
            scan.nextLine();
            Sys.sp(Globals.name() + " hit the ground too hard.");
            scan.nextLine();
            Globals.gameOver();
            break;
        case "t": 
            if(mirror)
            {
                Globals.takeItem("mirror");
                mirror = false;
            }
            else
            {
                System.out.println("There's no "+Parser.param()+" here");
            }
            break;
        default:
            break;
        }
    }


    public static String getLocat() {
        return (locat);
    }

    public static void changeLocat(String str, String command) {
        switch (str) {
        case "upperOldMainNorth":
            upperOldMainNorth(command);
            break;
        case "computerLab":
            computerLab(command);
            break;
        case "taberski":
            taberski(command);
            break;
        case "gallagher":
            gallagher(command);
            break;
        case "oldMainLounge":
            oldMainLounge(command);
            break;
        case "gym":
            gym(command);
            break;
        case "upperCourtyard":
            upperCourtyard(command);
            break;
        case "lowerOldMain":
            lowerOldMain(command);
            break;
        case "lockers":
            lockers(command);
            break;
        case "upperOldMainSouth":
            upperOldMainSouth(command);
            break;
        case "heathHall1East":
            heathHall1East(command);
            break;
        case "heathHall1West":
            heathHall1West(command);
            break;
        case "france":
            france(command);
            break;
        case "spain":
            spain(command);
            break;
        case "mock":
            mock(command);
            break;
        case "moynihan":
            moynihan(command);
            break;
        case "upperHeathHallEast":
            upperHeathHallEast(command);
            break;
        case "upperHeathHallWest":
            upperHeathHallWest(command);
            break;
        case "glass":
            glass(command);
            break;
        case "closet":
            closet(command);
            break;
        case "cafeteria":
            cafeteria(command);
            break;
        case "upperGraceHall":
            upperGraceHall(command);
            break;
        case "compLab":
            compLab(command);
            break;
        case "library":
            library(command);
            break;
        case "brodniak":
            brodniak(command);
            break;
        case "zelner":
            zelner(command);
            break;
        case "tmac":
            tmac(command);
            break;
        case "freshmanLockers":
            freshmanLockers(command);
            break;

       case "roof":
           roof(command);
           break;
        case "portables":
            portables(command);
            break;
        case "roboticsRoom":
            roboticsRoom(command);
            break;
            
        
        }
    }
}
